#include <thrust/graph/adjacency_list.hpp>
#include <thrust/graph/random.hpp>
#include <thrust/graph/simple_io.hpp>
using namespace thrust;

#include <iostream>
using namespace std;

#include <ctime>

void test( unsigned int N, unsigned int M, unsigned int seed)
{
  typedef adjacency_list<directedS,disallow_parallelS> graph_t;
  typedef graph_traits<graph_t>::edge_descriptor edge_descriptor;
  
  typedef thrust::random::default_random_engine  gen;
  
  clock_t start, finish;
  
  start =clock();
  graph_t g( N, M);
  thrust::generate_random_graph<gen>( g, N, M, false, false, seed);
  finish =clock();
  
  std::cout <<(double)(finish - start)/(double)CLOCKS_PER_SEC 
	    <<std::endl;

  //std::cout <<g <<std::endl;
}

int main( int argc, char* argv[])
{
  unsigned int N;
  unsigned int M;
  //unsigned int M =16777088 + 1;
  unsigned int seed =1;

  if ( argc ==3){
    N =atoi( argv[1]);
    M =atoi( argv[2]);
  }
  else if( argc ==4){
    N =atoi( argv[1]);
    M =atoi( argv[2]);
    seed =atoi( argv[3]); 
  }
  else {
    std::cerr <<"usage: random nodes edges seed" <<std::endl;
    exit( 1);
  }
  
  test( N, M, seed);

  return 0;
}
